from django.urls import path,re_path
from . import views

app_name = 'users'
urlpatterns = [
    # 用户注册
    path('register', views.Register.as_view(), name='register'),
    # 判断用户名是否重复
    re_path(r'^usernames/(?P<username>[a-zA-Z0-9-_]{5,20})/count/$', views.UsernameCountView.as_view()),
    # re_path(r'^mobiles/(?P<mobile>(?:\+86)?1[3-9]\d{9})/count/$', views.MobileCountView.as_view()),
    # 判断手机号是否重复
    re_path(r'^mobiles/(?P<mobile>(?:\+86)?1[3-9]\d{9})/count/$', views.MobileCountView.as_view()),
    # 登录
    path('login/', views.LoginView.as_view(), name='login'),
    # 退出登录
    path('logout', views.LogoutView.as_view(), name='logout'),
    # 用户中心
    path('userinfo', views.UserInfoView.as_view(), name='userInfo'),
    # 保存邮件
    path('emails/', views.EmailView.as_view()),
    # 邮箱激活验证
    path('emails/verification/', views.VerifyEmailView.as_view()),
    # 收货地址
    path('address/', views.AddressView.as_view(),name='address'),
    # 添加收货地址
    path('addresses/create/', views.CreateAndUpdateAddressView.as_view()),
    # 编辑收货地址
    re_path(r'^addresses/(?P<address_id>\d+)/$', views.CreateAndUpdateAddressView.as_view()),
    # 设置默认收货地址
    re_path(r'^addresses/(?P<address_id>\d+)/default/$', views.DefaultAddressView.as_view())
]
